package cn.itcast.servlet;

import cn.itcast.domain.User;
import cn.itcast.service.UserService;
import cn.itcast.service.impl.UserServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    private UserService service = new UserServiceImpl();

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取页面参数
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        System.out.println(username);
        //调用service
      /*  User user = service.login(username, password);
        System.out.println(user);*/

    /*    //判断user是否为空
        if (user!=null){ //登录成功 写到页面

            HttpSession session = req.getSession();
            session.setAttribute("user",user);

            resp.setHeader("Refresh","2;URL:/pages/success.html");
            resp.getWriter().write("欢迎你"+user.getUsername());

        }else{
            resp.getWriter().write("登录失败,请返回登录页面重新登录");
        }
        */

    }
}
